package com.hoshiicloud.saleorder.service.customer;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hoshiicloud.common.aop.Logable;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.saleorder.param.customer.CartDeleteParam;
import com.hoshiicloud.user.entity.customer.Cart;
import com.hoshiicloud.user.vo.customer.CartVO;
import java.util.List;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 购物车购物信息记录表 服务类
 * </p>
 *
 * @author Mr.Wu
 * @since 2019-04-28
 */
public interface ICartService extends IService<Cart> {

    Response insert(Cart param);

    Response updateDataById(Cart param);

    @Transactional(rollbackFor = Exception.class)
    @CacheEvict(cacheNames = {"Cart"}, allEntries = true)
    @Logable(authName = "前台用户操作-购物车购物信息记录表信息管理-删除购物车购物信息记录表信息")
    Response deleteDataByNumber(CartDeleteParam param);

    Response deleteDataById(String id);

    Response deleteDataByIds(List<Long> ids);

    Response getDetail(String id);

    Response<List<CartVO>> getList(QueryWrapper<Cart> queryWrapper, String key);

    Response<IPage<CartVO>> getPage(IPage<Cart> page, QueryWrapper<Cart> queryWrapper, String key);

    Response updateCartInfo(QueryWrapper<Cart> queryWrapper);

    @Cacheable(cacheNames = "Cart", key = "T(com.hoshiicloud.common.utils.DigestUtils).md5('Wrapper(SqlSelect=' + #queryWrapper.getSqlSelect() + ', SqlSegment=' + #queryWrapper.getSqlSegment() + ')')")
    @Logable(authName = "前台用户操作-购物车购物信息记录表信息管理-查询购物车数量")
    Integer getCount(QueryWrapper<Cart> queryWrapper);

    /**
     * 根据用户ID和店铺ID批量删除
     * @author yangcheng
     * @param userId    用户ID
     * @param storeId   店铺ID
     * @return Response
     */
    Response deleteByUserIdAndStoreId(Long userId,Long storeId);
}
